﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using NLBS.Control;

namespace NLBS.Blog.Admin.control
{
    public partial class Plugins : BaseUserControl
    {

        protected override void OnLoad(EventArgs e)
        {
            checkAdmin();
            bool existXmlFile=SiteConfig.CheckExtensionsXmlFile();
            if (!existXmlFile)
            {
                SiteConfig.CreateExtensionsXmlFile();
            }
            existXmlFile = SiteConfig.CheckExtensionsXmlFile();
            if(existXmlFile)
            Repeater1.DataSourceID="XmlDataSource1";
            base.OnLoad(e);
        }
       
        public string ShowPluginLink(object item)
        {
            bool enablePlugin = Convert.ToBoolean(XPathBinder.Eval(item, "Enabled"));
            string link=string.Empty;
            if (enablePlugin)
            {
                
                link = string.Format("<a href=javascript:AdminPlugin.Install('{0}','{1}')>{2}</a>", 
                    XPathBinder.Eval(item, "Name").ToString(),
                    XPathBinder.Eval(item, "InstalledPage").ToString(), lang["plugin_install"]);
            } else
            {
                link = string.Format("<a href=javascript:AdminPlugin.UnInstall('{0}','{1}')>{2}</a>", 
                    XPathBinder.Eval(item, "Name").ToString(),
                    XPathBinder.Eval(item, "InstalledPage").ToString(), lang["plugin_uninstall"]);
            }
            return link;
        }
    }
}